#include "SPI.h"
/*PB5:SPI1_MOSI PB3:SPI1_SCK PA15:CS1*/
void SPI_Init(void)
{
    /*使能时钟*/
    RCC->APBENR2 |= (1<<12);
    /*配置IO，复用输出，高速，CS拉高*/
    GPIOA->MODER &= 0x3fffffff;
    GPIOA->MODER |= 0x40000000;
    GPIOA->OSPEEDR |= 0x80000000;
    GPIOA->ODR |= (1<<15);

    GPIOB->MODER &= 0xfffff33f;
    GPIOB->MODER |= 0x00000880;
    GPIOB->OSPEEDR &= 0xfffff33f;
    GPIOB->OSPEEDR |= 0x00000880;
    /*配置SPI,主机模式，空闲电平为低，第一个沿采样，速率2M*/
    SPI1->CR1 = 0x0314;
    SPI1->CR2 = 0x0700;
    /*使能SPI*/
    SPI1->CR1 |= (1<<6);
}
